<?php

require_once __DIR__.'/../../lib/PAutoLoader.php';

use Thrift\Protocol\TBinaryProtocol;
use Thrift\Protocol\TMultiplexedProtocol;
use Thrift\Transport\THttpClient;
use Thrift\Transport\TBufferedTransport;
use Thrift\Exception\TException;
use com\penngo\LoginServiceClient;

try {
  $trans = new THttpClient('localhost', 8080, '');
  
  $transport = new TBufferedTransport($trans);
  $protocol = new TBinaryProtocol($transport);
//   $thriftServiceProtocol = new TMultiplexedProtocol($protocol, 'ThriftService');
//   $thriftServiceClient = new \Swoole\Service\ThriftServiceClient($thriftServiceProtocol);
//   $servers = $thriftServiceClient->getServers();
//   var_dump($servers);
  
  $thriftServiceProtocol = new TMultiplexedProtocol($protocol, 'LoginService');
//   new  LoginServiceClient
    $loginServiceClient = new LoginServiceClient($thriftServiceProtocol);
    $rec = $loginServiceClient->login("penngo", "123");
    var_dump($rec);
//   $transport->close();
} catch (TException $tx) {
  print 'TException: '.$tx->getMessage()."\n";
}

?>
